package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.CourseTalk;
import com.hl.sfzy.mapper.CourseTalkMapper;
import com.hl.sfzy.service.CourseTalkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service


public class CourseTalkServiceImpl implements CourseTalkService {
    @Autowired
    private CourseTalkMapper courseTalkMapper;


    @Override
    public int removeByPrimaryKey(Long id) {
        return courseTalkMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(CourseTalk courseTalk) {
        return courseTalkMapper.insert(courseTalk);
    }

    @Override
    public CourseTalk findByPrimaryKey(Long id) {
        return courseTalkMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKey(CourseTalk courseTalk) {
        return courseTalkMapper.updateByPrimaryKey(courseTalk);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return courseTalkMapper.deleteBatch(ids);
    }

    @Override
    public List<CourseTalk> find(int pageNum, int pageSize) {
        return courseTalkMapper.select(pageNum, pageSize);
    }

    @Override
    public PageInfo<CourseTalk> findByPage(int pageNum, int pageSize, CourseTalk courseTalk) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseTalk> courseTalks = courseTalkMapper.selectByPage(pageNum, pageSize, courseTalk);
        PageInfo<CourseTalk> pageInfo = new PageInfo<>(courseTalks);
        return pageInfo;

    }
}
